﻿using System;
using SKBKontur.Logging;
using SKBKontur.Logging.Model;

namespace SKBKontur.Cassandra.Logging.Helpers
{
    public static class LogEventWriterExtensions
    {
        public static void Info(this ILogEventWriter logEventWriter, string message)
        {
            logEventWriter.Create(new LogEvent
                                      {Message = message, TimeStamp = DateTime.Now, EventLevel = LogEventLevel.Info});
        }

        public static void Warn(this ILogEventWriter logEventWriter, string message)
        {
            logEventWriter.Create(new LogEvent
                                      {Message = message, TimeStamp = DateTime.Now, EventLevel = LogEventLevel.Warn});
        }

        public static void Error(this ILogEventWriter logEventWriter, string message, Exception e)
        {
            logEventWriter.Create(new LogEvent(e)
                                      {Message = message, TimeStamp = DateTime.Now, EventLevel = LogEventLevel.Error});
        }

        public static void Debug(this ILogEventWriter logEventWriter, string message)
        {
            logEventWriter.Create(new LogEvent
                                      {Message = message, TimeStamp = DateTime.Now, EventLevel = LogEventLevel.Debug});
        }

        public static void Fatal(this ILogEventWriter logEventWriter, string message, Exception e)
        {
            logEventWriter.Create(new LogEvent(e)
                                      {Message = message, TimeStamp = DateTime.Now, EventLevel = LogEventLevel.Fatal});
        }
    }
}